package com.mangowang.module.main.ui;

/**
 * 文件名 : EarningDetailActivity
 * 创建者 : MangoWang
 * 创建日期 : 2019/11/28 20:06
 * 微信 : MangoWaWang
 * 邮箱 : 763482205@qq.com
 * 描述 : TODO
 */

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.google.protobuf.InvalidProtocolBufferException;
import com.mangowang.lib.common.base.BaseActivity;
import com.mangowang.lib.common.help.UserHelper;
import com.mangowang.lib.common.net.Apis;
import com.mangowang.lib.common.net.NetworkManager;
import com.mangowang.lib.common.net.interfaces.OnRequestCallBack;
import com.mangowang.lib.common.proto.Mystock;
import com.mangowang.lib.common.util.StatusBarUtil;
import com.mangowang.module.main.R;
import com.mangowang.module.main.R2;
import com.mangowang.module.main.adapter.ShopAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

public class ShopActivity extends BaseActivity {

    Unbinder unbinder;
    @BindView(R2.id.recyclerView)
    RecyclerView recyclerView;
    @BindView(R2.id.tv_title)
    TextView tvTitle;
    @BindView(R2.id.tv_machine)
    TextView tv_machine;
    @BindView(R2.id.tv_machine_total)
    TextView tv_machine_total;

    private ShopAdapter mAdapter;
    private List<Mystock.goods> datas = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop);
        unbinder = ButterKnife.bind(this);
        StatusBarUtil.setStatusBarLightMode(this, Color.parseColor("#FFFFFF"), true);
        tvTitle.setText("商户");
        initRecyclerView();
        initData();
    }


    private void initData() {






//
//        Mystock.goods_merchnat.Builder builder = Mystock.goods_merchnat.newBuilder();
//        builder.setMemberId(UserHelper.getUser().getMember_id());
//        NetworkManager.INSTANCE.post(Apis.goods_merchant, builder.build().toByteArray(), new OnRequestCallBack() {
//            @Override
//            public void onOk(byte[] response) throws InvalidProtocolBufferException {
//                Mystock.goods_merchnat bean = Mystock.goods_merchnat.parseFrom(response);
//                List<Mystock.list_basis> list = bean.getListDesList();
//                StringBuilder des = new StringBuilder();
//                for (int i = 0; i < list.size() - 1; i++) {
//                    des.append(list.get(i).getName()).append("\n");
//                }
//                des.append(list.get(list.size() - 1).getName());
//                datas = Mystock.goods_merchnat.parseFrom(response).getListList();
//                Log.e("datas", datas.toString());
//               tv_machine.setText( bean.getMerchant());
//               tv_machine_total.setText(bean.getMerchantTotal());
//               mAdapter.addData(datas);
//            }
//
//            @Override
//            public void onError(int errorCode, String errorMessage) {
//                showToast(errorMessage);
//            }
//        });


    }

    private void initRecyclerView() {
//        recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
//        recyclerView.setAdapter(mAdapter = new ShopAdapter(mContext, datas));
////        mAdapter.setEmptyView(R.layout.empty_shop);
//        // 每个item的点击事件
//        mAdapter.setOnItemClickListener((adapter, view, position) -> {
//            Intent intent = new Intent(mContext, ShopNextActivity.class);
//            intent.putExtra("goods_name", mAdapter.getData().get(position).getGoodsSerial() + " "+
//                    mAdapter.getData().get(position).getGoodsName() + " 商户");
//            intent.putExtra("goods_id", mAdapter.getData().get(position).getGoodsCommonid());
//            startActivity(intent);
//
//        });
    }


    @Override
    protected void onResume() {
        super.onResume();
    }
}
